import time

import requests
import json

# headers = {
#     "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
# }
# cookies = {
#     "Hm_lvt_94a1e06bbce219d29285cee2e37d1d26": "1733140650",
#     "HMACCOUNT": "CCBDA8F22B52E93D",
#     "menuIds": "[25949,143064,128409,26916,25950,122908,25951,119908,136261,36079,119489,25952,25953,26161,-8,143022,143065,-21,-24,122153,143013,-1]",
#     "ariaDefaultTheme": "undefined",
#     "Hm_lpvt_94a1e06bbce219d29285cee2e37d1d26": "1733140720",
#     "tfstk": "fo6Ipv2fq20CxxFUG0Ew5OZtG5pWNaw4A0tRmgHE2ppKy4Iv7Y7zxLJ52ZSyw9SypUi5zNRPTayH6AKecUQ5qkxJyaQWz6Pa3MjHELUVF-yVx2MFQOQW9LK9BGxkyDUUofBDELU47F3woqvloB4j7TITf3-Sv4QJJGI9S3tpvaLp6VKXmLpJeaptBHx-v3HJJRK9S3pJyap-MTnXVWThAlWcx24qrMIp5xsGCHIxtMT_5PB11BTvuFM-eOtCbwGLnxNyksYegUbTQv95X3_e7ZexCddfig-5RJMpL1CGKpWal4RCPFR5pKi8pG9BRIBB_DHCkGsRgC6aD-vBpeCyKgob8G6C8MX140h9dp56G99Yn2LP_i6WVT4uCZscINtOk8ad4mk2lGD-NcOmFhT4flGoZG8uhTlWmRpJ9hxB_lZsJ_Apjhs8flGriBKMbwq_fjrV."
# }
# url = "https://www.thepaper.cn/channel_25950"
# response = requests.get(url, headers=headers,)
#
# print(response.text)
# print(response)
# print(time.time()*1000)
start_time = int(time.time()*1000)
headers = {
    "content-type": "application/json",
    "referer": "https://www.thepaper.cn/",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
}

url = "https://api.thepaper.cn/contentapi/nodeCont/getByChannelId"
page = 1
while page < 4:
    page += 1
    data = {
        "channelId": "25950",
        "province": None,
        "pageSize": 20,
        "pageNum": page,
        "startTime": start_time
    }
    data = json.dumps(data, separators=(',', ':'))
    response = requests.post(url, headers=headers, data=data)
    # print(response.text)
    print(response)
    res = response.json()
    information_list = res["data"]["list"]
    print(res['data']['pageNum'])
    for information in information_list:
        print(information["name"])
